<%-- 
    Document   : shoppingcart
    Created on : Jan 13, 2013, 3:39:17 PM
    Author     : KAKAIT
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="model.entity.Product"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<script type="text/javascript">
    //&lt;![CDATA[
        window.document.title ="Shopping Cart";
    //]]&gt;
    </script>
<div class="col-main" id="ves-col-main">
    
    <%
     List<Product> lprocart = (List<Product>)session.getAttribute("shoppingcart");
     double grand_Total = 0;
    if(lprocart !=null)
        {
%>
    
    <div class="cart">
        <div class="page-title title-buttons">
            <h1>Shopping Cart</h1>
            <ul class="checkout-types">
                <li><button onclick="window.location='#';" class="button btn-proceed-checkout btn-checkout" title="Proceed to Checkout" type="button"><span><span>Proceed to Checkout</span></span></button>
                </li>
            </ul>
        </div>
        <form method="post" action="#">
            <fieldset>
                <table class="data-table cart-table" id="shopping-cart-table">
                    <colgroup>
                        <col width="1">
                        <col>
                        <col width="1">
                        <col width="1">
                        <col width="1">
                        <col width="1">
                        <col width="1">
                    </colgroup>
                    <thead>
                        <tr class="first last">
                            <th rowspan="1"><span class="nobr">Product Image</span></th>
                            <th rowspan="1" class="sct-name"><span class="nobr">Product Name</span></th>
                            <th rowspan="1" class="sct-edit"></th>
                                                    <th colspan="1" class="a-center"><span class="nobr">Unit Price</span></th>
                            <th rowspan="1" class="sct-quantity">Qty</th>
                            <th colspan="1" class="a-center">Subtotal</th>
                            <th rowspan="1" class="last">&nbsp;</th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr class="first last">
                            <td class="a-right last" colspan="50">
                                <button onclick="setLocation('<c:url value="/homepage"/>')" class="button btn-continue" title="Continue Shopping" type="button"><span><span>Continue Shopping</span></span></button>
                                <button class="button btn-update" title="Update Shopping Cart" type="button" onclick="setLocation('<c:url value="/shoppingcart"/>')"><span><span>Update Shopping Cart</span></span></button>
                            </td>
                        </tr>
                    </tfoot>
                    <tbody>
                <%
                for(int i = 0; i < lprocart.size();i++)
                {
                    double money = lprocart.get(i).getTotalamount() * lprocart.get(i).getQuantity();
                    
                    grand_Total += money;
                    
                    %>
                    
                        <tr class="">
                            <td><a class="product-image" title="<%= lprocart.get(i).getProductname() %>" href="<c:url value="/detailproduct"><c:param name="id" value="<%= String.valueOf(lprocart.get(i).getProductid())%>"></c:param></c:url>"><img width="150" height="150" alt="" src="images/product/<%= lprocart.get(i).getPicture().toString() %>"></a>
                            </td>
                            <td class="sct-name">
                                <h3 class="product-name"><a href="<c:url value="/detailproduct"><c:param name="id" value="<%= String.valueOf(lprocart.get(i).getProductid())%>"></c:param></c:url>"><%= lprocart.get(i).getProductname() %></a></h3>
                            </td>
                            <td class="a-center sct-edit">
                                <a title="Edit item parameters" href="<c:url value="/detailproduct"><c:param name="id" value="<%= String.valueOf(lprocart.get(i).getProductid())%>"></c:param></c:url>">Edit</a>
                            </td>
    
    
                            <td class="a-right">
                                    <span class="cart-price"><span class="price">$<%= Double.toString(lprocart.get(i).getTotalamount()) %></span></span>
                            </td>
                            <td class="a-center sct-quantity">
                                <span class="cart-price"><span class="price"><%= lprocart.get(i).getQuantity() %></span></span>
                                
                            </td>
                            <td class="a-right sct-price">
                                <span class="cart-price"><span class="price">$<%= Double.toString(money) %></span></span>
                            </td>
                            <td class="a-center last"><a class="btn-remove btn-remove2" title="Remove item" href="<c:url value="/removeItemCart"><c:param name="id" value="<%= String.valueOf(lprocart.get(i).getProductid())%>"></c:param></c:url>">Remove item</a>
                            </td>
                        </tr>
                <%}%>
                    </tbody>
                </table>
              <script type="text/javascript">decorateTable('shopping-cart-table', ['odd', 'even', 'first', 'last'])</script>      
            </fieldset>
        </form>
        <div class="cart-collaterals">
            <div class="totals">
                <table id="shopping-cart-totals-table">
                <colgroup><col>
                <col width="1">
                </colgroup>
                <tfoot>
                    <tr>
            <td colspan="1" class="a-right" style="">
                <strong>Grand Total</strong>
            </td>
            <td class="a-right" style="">
                <strong><span class="price">$<%= Double.toString(grand_Total) %></span></strong>
            </td>
        </tr>
                </tfoot>
        <tbody>
            <tr>
    <td colspan="1" class="a-right" style="">
        Subtotal    </td>
    <td class="a-right" style="">
        <span class="price">$<%= grand_Total %></span>    </td>
</tr>
        </tbody>
    </table>
                        <ul class="checkout-types">
                                                                                                    <li>    <button onclick="window.location='<c:url value="/selectpayment"/>';" class="button btn-proceed-checkout btn-checkout" title="Proceed to Checkout" type="button"><span><span>Proceed to Checkout</span></span></button>
</li>
                                                                    </ul>
                    </div>
    </div>
</div>

<% 
    }
        else if(lprocart == null || lprocart.size() ==0) {
%>		
    <div class="page-title">
        <h1>Shopping Cart is Empty</h1>
    </div>
    <div class="cart-empty">
        <p>You have no items in your shopping cart.</p>
        <p>Click <a href="<c:url value="/homepage"/>">here</a> to continue shopping.</p>
    </div>                
<%}%>						
                                         <!-- end main content -->     
</div>

